package com.xcity.game.rank.impl;

import java.util.Comparator;

import com.xcity.db.entity.Player;
import com.xcity.db.entity.Ranking;
import com.xcity.game.event.GameEvents;
import com.xcity.game.rank.BaseRankingList;

import naga.x.event.Event;

public class LevelRankingList extends BaseRankingList {

	public LevelRankingList(int type, int capacity, Comparator<Ranking> comparator) {
		super(type, capacity, comparator);
	}

	@Override
	public int[] getEventTypes() {
		return new int[] { GameEvents.EVENT_PLAYER_LEVEL_UP };
	}

	@Override
	public void handleEvent(Event event) {
		Player player = event.getParameter();
		long val = ((long) player.getLevel() << 32) | player.getExp();
		setDirty(player, val);
	}

}
